package com.wangzhixuan.commons.utils;

import java.io.File;
import java.util.Iterator;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class ReadXmlUtil {
	public static String host;
	public static String port;
	public static String service_name;
	public static String user;
	public static String password;
	public static String directory;
	public static String protocol;
	public static String datagriddataurl;

	static {
		readDefaultInfo();
	}

	public static void readDefaultInfo() {
		try {
			File e = new File(ReadXmlUtil.class.getResource("/").getPath() + "\\info.xml");
			System.out.println();
			SAXReader reader = new SAXReader();
			Document doc = reader.read(e);
			Element root = doc.getRootElement();

			Element foo;
			for (Iterator i = root.elementIterator("info"); i
					.hasNext(); datagriddataurl = foo.elementText("datagriddataurl")) {
				foo = (Element) i.next();
				host = foo.elementText("host");
				port = foo.elementText("port");
				service_name = foo.elementText("service_name");
				user = foo.elementText("user");
				password = foo.elementText("password");
				directory = foo.elementText("directory");
				protocol = foo.elementText("protocol");
			}
		} catch (Exception arg5) {
			arg5.printStackTrace();
		}

	}

	public static void main(String[] args) {
		readDefaultInfo();
	}
}